Move extract-strings to its own directory
authorMatthias Clasen <mclasen@redhat.com>
Tue, 27 May 2014 19:54:38 +0000 (15:54 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 27 May 2014 21:28:10 +0000 (17:28 -0400)
This will hopefully help resolve the circular dependency between
libgtk linking against inspector/libgtkinspector and inspector/
needing extract-strings from gtk/.

I didn't preserve the EXEEXT decorations in this operation -
automake gave me stern warnings about it, so I just dropped them
all. Somebody who cross-builds GTK+ will have to reconstruct this.

configure.ac
gtk/Makefile.am
gtk/extract-strings.c [deleted file]
gtk/inspector/Makefile.am
util/Makefile.am [new file with mode: 0644]
util/extract-strings.c [new file with mode: 0644]

index b07a87824a99c378087d8b993c7f9207fb33352e..a152fc40ef95bee0d6254d58768571328fa8c1f9 100644 (file)
@@ -1888,6 +1888,7 @@ gtk/gtkversion.h
 gtk/gtk-win32.rc
 gtk/inspector/Makefile
 gtk/native/Makefile
+util/Makefile
 libgail-util/Makefile
 modules/Makefile
 modules/input/Makefile
index ac3295c6880929bf3abcc696f564ab67011cd4d1..45086bbd3ac3a90bbfc7ddf6683e146b6ab3d9c6 100644 (file)
@@ -1321,9 +1321,9 @@ COMPOSITE_TEMPLATES =                             \
 
 template_headers = $(COMPOSITE_TEMPLATES:.ui=.ui.h)
 
-%.ui.h: %.ui extract-strings$(BUILD_EXEEXT)
+%.ui.h: %.ui
        $(AM_V_GEN) mkdir -p $(dir $@) \
-       && ./extract-strings$(BUILD_EXEEXT) $< > $@
+       && $(top_builddir)/util/extract-strings$(BUILD_EXEEXT) $< > $@
 
 #
 # rules to generate built sources
@@ -1616,17 +1616,6 @@ endif
 gtk_launch_LDADD = $(LDADDS)
 gtk_launch_SOURCES = gtk-launch.c
 
-# The extract_strings tool is a build utility that runs on the build system.
-extract_strings_sources = extract-strings.c
-extract_strings_cppflags =
-extract_strings_cflags = $(GLIB_CFLAGS_FOR_BUILD)
-extract_strings_ldadd = $(GLIB_LIBS_FOR_BUILD)
-extract-strings$(BUILD_EXEEXT): $(extract_strings_sources)
-       @rm -f extract-strings$(BUILD_EXEEXT)
-       $(AM_V_CCLD)$(CC_FOR_BUILD) $(extract_strings_cppflags) $(CPPFLAGS_FOR_BUILD) $(extract_strings_cflags) $(CFLAGS_FOR_BUILD) $^ $(LDFLAGS_FOR_BUILD) $(extract_strings_ldadd) $(LIBS_FOR_BUILD) -o $@
-EXTRA_DIST += $(extract_strings_sources)
-DISTCLEANFILES += extract-strings
-
 .PHONY: files test test-debug
 
 files:
diff --git a/gtk/extract-strings.c b/gtk/extract-strings.c
deleted file mode 100644 (file)
index 183b99a..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2013 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <glib.h>
-
-typedef struct {
-  GString *output;
-  gboolean translatable;
-  gchar *context;
-  gchar *comments;
-  GString *text;
-} ParserData;
-
-static void
-start_element_handler (GMarkupParseContext  *contexts,
-                       const gchar          *element_name,
-                       const gchar         **attribute_names,
-                       const gchar         **attribute_values,
-                       gpointer              user_data,
-                       GError              **error)
-{
-  ParserData *data = user_data;
-
-  if (g_str_equal (element_name, "property") ||
-      g_str_equal (element_name, "attribute") ||
-      g_str_equal (element_name, "item"))
-    {
-      gboolean translatable;
-      gchar *context;
-      gchar *comments;
-
-      g_markup_collect_attributes (element_name,
-                                   attribute_names,
-                                   attribute_values,
-                                   error,
-                                   G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "name", NULL,
-                                   G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "value", NULL,
-                                   G_MARKUP_COLLECT_TRISTATE, "translatable", &translatable,
-                                   G_MARKUP_COLLECT_STRDUP|G_MARKUP_COLLECT_OPTIONAL, "context", &context,
-                                   G_MARKUP_COLLECT_STRDUP|G_MARKUP_COLLECT_OPTIONAL, "comments", &comments,
-                                   G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "id", NULL,
-                                   G_MARKUP_COLLECT_INVALID);
-
-      if (translatable == TRUE)
-        {
-          data->translatable = TRUE;
-          data->context = context;
-          data->comments = comments;
-          data->text = g_string_new ("");
-        }
-    }
-}
-
-static void
-end_element_handler (GMarkupParseContext  *context,
-                     const gchar          *element_name,
-                     gpointer              user_data,
-                     GError              **error)
-{
-  ParserData *data = user_data;
-  gchar **lines;
-  gint i;
-
-  if (!data->translatable)
-    return;
-
-  lines = g_strsplit (data->text->str, "\n", -1);
-
-  if (data->comments)
-    g_string_append_printf (data->output, "\n/* %s */\n",
-                            data->comments);
-
-  if (data->context)
-    g_string_append_printf (data->output, "C_(\"%s\", ",
-                            data->context);
-  else
-    g_string_append (data->output, "N_(");
-
-  for (i = 0; lines[i]; i++)
-    g_string_append_printf (data->output, "%s\"%s%s\"%s",
-                            i > 0 ? "   " : "",
-                            lines[i],
-                            lines[i+1] ? "\\n" : "",
-                            lines[i+1] ? "\n" : "");
-
-  g_string_append (data->output, ");\n");
-
-  g_strfreev (lines);
-
-  g_free (data->comments);
-  g_free (data->context);
-  g_string_free (data->text, TRUE);
-
-  data->comments = NULL;
-  data->context = NULL;
-  data->text = NULL;
-  data->translatable = FALSE;
-}
-
-static void
-text_handler (GMarkupParseContext  *context,
-              const gchar          *text,
-              gsize                 text_len,
-              gpointer              user_data,
-              GError              **error)
-{
-  ParserData *data = user_data;
-
-  if (!data->translatable)
-    return;
-
-  g_string_append_len (data->text, text, text_len);
-}
-
-static const GMarkupParser parser = {
-  start_element_handler,
-  end_element_handler,
-  text_handler,
-  NULL,
-  NULL
-};
-
-int
-main (int argc, char *argv[])
-{
-  gchar *contents;
-  gsize length;
-  GError *error;
-  GMarkupParseContext *context;
-  ParserData data;
-
-  if (argc < 2)
-    {
-      g_printerr ("Expect a filename\n");
-      return 1;
-    }
-
-  error = NULL;
-  if (!g_file_get_contents (argv[1], &contents, &length, &error))
-    {
-      g_printerr ("%s\n", error->message);
-      g_error_free (error);
-      return 1;
-    }
-
-  data.output = g_string_new ("");
-  data.translatable = FALSE;
-
-  context = g_markup_parse_context_new (&parser, 0, &data, NULL);
-  if (!g_markup_parse_context_parse (context, contents, length, &error))
-    {
-      g_markup_parse_context_free (context);
-      g_free (contents);
-      g_printerr ("%s\n", error->message);
-      g_error_free (error);
-      return 1;
-    }
-
-  g_print ("%s", g_string_free (data.output, FALSE));
-
-  return 0;
-}
index 574b4c1ebe374d3ef9a222b92fb7bcc927019623..67e9c4ed885f438ef3d9470d221da5a1784bd7eb 100644 (file)
@@ -6,13 +6,14 @@ resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --gener
 resources.h: inspector.gresource.xml
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/inspector.gresource.xml \
                --target=$@ --sourcedir=$(srcdir) --c-name gtk_inspector --generate-header --manual-register
-resources.c: inspector.gresource.xml $(resource_files) $(template_headers)
+resources.c: inspector.gresource.xml $(resource_files)
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/inspector.gresource.xml \
                --target=$@ --sourcedir=$(srcdir) --c-name gtk_inspector --generate-source --manual-register
 
 BUILT_SOURCES =                        \
        resources.h                     \
-       resources.c
+       resources.c                     \
+       $(template_headers)
 
 libgtkinspector_la_SOURCES =           \
        actions.h                       \
@@ -98,11 +99,9 @@ templates =                          \
 
 template_headers = $(templates:.ui=.ui.h)
 
-BUILT_SOURCES += $(template_headers)
+extract_strings = $(top_builddir)/util/extract-strings
 
-extract_strings = $(top_builddir)/gtk/extract-strings$(BUILD_EXEEXT)
-
-%.ui.h: %.ui $(extract_strings)
+%.ui.h : %.ui 
        $(AM_V_GEN) $(extract_strings) $< > $@
 
 EXTRA_DIST +=                          \
@@ -112,7 +111,7 @@ EXTRA_DIST +=                               \
 
 MAINTAINERCLEANFILES =                 \
        resources.c                     \
-       resources.h
+       resources.h                     \
        $(template_headers)
 
 distclean-local:
diff --git a/util/Makefile.am b/util/Makefile.am
new file mode 100644 (file)
index 0000000..f079800
--- /dev/null
@@ -0,0 +1,11 @@
+# The extract_strings tool is a build utility that runs on the build system.
+extract_strings_sources = extract-strings.c
+extract_strings_cppflags =
+extract_strings_cflags = $(GLIB_CFLAGS_FOR_BUILD)
+extract_strings_ldadd = $(GLIB_LIBS_FOR_BUILD)
+
+extract-strings: $(extract_strings_sources)
+       @rm -f extract-strings
+       $(AM_V_CCLD)$(CC_FOR_BUILD) $(extract_strings_cppflags) $(CPPFLAGS_FOR_BUILD) $(extract_strings_cflags) $(CFLAGS_FOR_BUILD) $^ $(LDFLAGS_FOR_BUILD) $(extract_strings_ldadd) $(LIBS_FOR_BUILD) -o $@
+
+noinst_PROGRAMS = extract-strings
diff --git a/util/extract-strings.c b/util/extract-strings.c
new file mode 100644 (file)
index 0000000..183b99a
--- /dev/null
@@ -0,0 +1,176 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+
+typedef struct {
+  GString *output;
+  gboolean translatable;
+  gchar *context;
+  gchar *comments;
+  GString *text;
+} ParserData;
+
+static void
+start_element_handler (GMarkupParseContext  *contexts,
+                       const gchar          *element_name,
+                       const gchar         **attribute_names,
+                       const gchar         **attribute_values,
+                       gpointer              user_data,
+                       GError              **error)
+{
+  ParserData *data = user_data;
+
+  if (g_str_equal (element_name, "property") ||
+      g_str_equal (element_name, "attribute") ||
+      g_str_equal (element_name, "item"))
+    {
+      gboolean translatable;
+      gchar *context;
+      gchar *comments;
+
+      g_markup_collect_attributes (element_name,
+                                   attribute_names,
+                                   attribute_values,
+                                   error,
+                                   G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "name", NULL,
+                                   G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "value", NULL,
+                                   G_MARKUP_COLLECT_TRISTATE, "translatable", &translatable,
+                                   G_MARKUP_COLLECT_STRDUP|G_MARKUP_COLLECT_OPTIONAL, "context", &context,
+                                   G_MARKUP_COLLECT_STRDUP|G_MARKUP_COLLECT_OPTIONAL, "comments", &comments,
+                                   G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "id", NULL,
+                                   G_MARKUP_COLLECT_INVALID);
+
+      if (translatable == TRUE)
+        {
+          data->translatable = TRUE;
+          data->context = context;
+          data->comments = comments;
+          data->text = g_string_new ("");
+        }
+    }
+}
+
+static void
+end_element_handler (GMarkupParseContext  *context,
+                     const gchar          *element_name,
+                     gpointer              user_data,
+                     GError              **error)
+{
+  ParserData *data = user_data;
+  gchar **lines;
+  gint i;
+
+  if (!data->translatable)
+    return;
+
+  lines = g_strsplit (data->text->str, "\n", -1);
+
+  if (data->comments)
+    g_string_append_printf (data->output, "\n/* %s */\n",
+                            data->comments);
+
+  if (data->context)
+    g_string_append_printf (data->output, "C_(\"%s\", ",
+                            data->context);
+  else
+    g_string_append (data->output, "N_(");
+
+  for (i = 0; lines[i]; i++)
+    g_string_append_printf (data->output, "%s\"%s%s\"%s",
+                            i > 0 ? "   " : "",
+                            lines[i],
+                            lines[i+1] ? "\\n" : "",
+                            lines[i+1] ? "\n" : "");
+
+  g_string_append (data->output, ");\n");
+
+  g_strfreev (lines);
+
+  g_free (data->comments);
+  g_free (data->context);
+  g_string_free (data->text, TRUE);
+
+  data->comments = NULL;
+  data->context = NULL;
+  data->text = NULL;
+  data->translatable = FALSE;
+}
+
+static void
+text_handler (GMarkupParseContext  *context,
+              const gchar          *text,
+              gsize                 text_len,
+              gpointer              user_data,
+              GError              **error)
+{
+  ParserData *data = user_data;
+
+  if (!data->translatable)
+    return;
+
+  g_string_append_len (data->text, text, text_len);
+}
+
+static const GMarkupParser parser = {
+  start_element_handler,
+  end_element_handler,
+  text_handler,
+  NULL,
+  NULL
+};
+
+int
+main (int argc, char *argv[])
+{
+  gchar *contents;
+  gsize length;
+  GError *error;
+  GMarkupParseContext *context;
+  ParserData data;
+
+  if (argc < 2)
+    {
+      g_printerr ("Expect a filename\n");
+      return 1;
+    }
+
+  error = NULL;
+  if (!g_file_get_contents (argv[1], &contents, &length, &error))
+    {
+      g_printerr ("%s\n", error->message);
+      g_error_free (error);
+      return 1;
+    }
+
+  data.output = g_string_new ("");
+  data.translatable = FALSE;
+
+  context = g_markup_parse_context_new (&parser, 0, &data, NULL);
+  if (!g_markup_parse_context_parse (context, contents, length, &error))
+    {
+      g_markup_parse_context_free (context);
+      g_free (contents);
+      g_printerr ("%s\n", error->message);
+      g_error_free (error);
+      return 1;
+    }
+
+  g_print ("%s", g_string_free (data.output, FALSE));
+
+  return 0;
+}